package com.sx.zongzhi.presenter;

import com.sx.zongzhi.bean.UserBean;
import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.view.ILoginView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by XZY on 2017/11/30.
 */

public class LoginPest {

    private ILoginView iLoginView;

    public LoginPest(ILoginView iLoginView) {
        this.iLoginView=iLoginView;
    }

    public void login(String name,String password){
        Map<String,Object> map=new HashMap<>();
        map.put("userName",name);
        map.put("password",password);
        new ApiManager().login(map, new BaseCallBack<BaseResult<UserBean>>() {
            @Override
            public void onSuccess(BaseResult<UserBean> response) {

                iLoginView.login(response.getData());
            }
            @Override
            public void onFailures(String message) {
                iLoginView.showError(message);
            }
        });
    }
}
